﻿using System;
using System.Data;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using PolePositionMobileUtilityEntity.Logic;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityEntity.Entities
{
    public class EProject : EBaseLookup
    {
        private EVendor m_Vendor;


        public EVendor Vendor
        {
            get { return m_Vendor; }
        }

        public EProject()
        :base()
        {
            m_Vendor = new EVendor();
            m_TableName = "tb_Projects";
            m_TableCollumnId = "ProjectId";
        }

        public EProject(Int32 id, string name)
            :this()
        {
            Id = id;
            Name = name;
        }
        public EProject(Int32 id, string name, Int32 idVendor)
            : this(id,name)
        {
            m_Vendor = new EVendor(idVendor);
        }

        protected override System.Data.DataTable SelectAll()
        {
            return LVendor.SelectProjects();
        }

        public EProject[] GetAll()
        {
            DataTable _dtProjects = SelectAll();

            EProject[] arr = new EProject[_dtProjects.Rows.Count];
            for (int i = 0; i < _dtProjects.Rows.Count; i++)
            {
                arr[i] = new EProject(ConvertMobileHelper.ToInt32(_dtProjects.Rows[i][m_TableCollumnId]), ConvertMobileHelper.Tostring(_dtProjects.Rows[i][m_TableCollumnName]), ConvertMobileHelper.ToInt32(_dtProjects.Rows[i]["VendorFk"]));
            }
            return arr;
        }
    }
}
